
from src import data_clean
from src import apriori
from src import fptree

def use_apriori():
    print("Hello World\n")
    data = data_clean.data_clean('./data/GoodsOrder.csv')
    trans_data = apriori.transformDataSet(data)
    support = 0.02
    confidence = 0.35
    result = apriori.find_rule(trans_data, support, confidence)
    result.to_csv('./tmp/apriori_rule.csv', index=True, header=True, encoding='utf-8')
    return

def use_fptree():
    data = data_clean.data_clean('./data/GoodsOrder.csv')
    trans_data = fptree.transformDataSet(data)
    support = 0.02
    confidence = 0.35
    f = fptree.FP_tree(trans_data, support, confidence)
    result = f.find_rule()
    result.to_csv('./tmp/fptree_rule.csv', index=True, header=True, encoding='utf-8')
    print(len(result))
    return

if __name__ == '__main__':
    use_apriori()
    use_fptree()